package com.leet.competition;

import javafx.util.Pair;

import java.math.BigDecimal;
import java.util.*;

public class InterChangable {
    public long compute(long n){
        return (n*(n-1))/2;
    }
    public long interchangeableRectangles(int[][] rectangles) {
        Map<BigDecimal,Integer> map = new HashMap<>();
        for(int[] a:rectangles){
            System.out.print(((double)a[0]/(double)a[1]));
            map.put(BigDecimal.valueOf(((double)a[0]/(double)a[1])),map.getOrDefault(BigDecimal.valueOf(((double)a[0]/(double)a[1])),0)+1);
        }
        long ans = 0;
        for(Map.Entry<BigDecimal,Integer> entry:map.entrySet()){
            if(entry.getValue()!=0&&entry.getValue()!=1) ans+=compute(entry.getValue());
        }
        return ans;
    }

}
